<template>
    <div class="cmt-container">
        <h3>商品评论</h3>
        <hr>
        <textarea placeholder="请输入要评论的内容(最多120字)" maxlength="120">
        </textarea>

        <mt-button type="primary" size="large" @click="postComment">发表评论</mt-button>
        <div class="cmt-list">
           <div class="cmt-item" v-for="(item,index) in comment" :key="index">
               <div class="cmt-title">
                第{{index+1}}楼&nbsp;&nbsp;用户: {{item.userNick}}&nbsp;&nbsp;发表时间: {{item.feedbackDate}}
               </div>
               <div class="cmt-body"></div>
                   {{item.feedback}}
               </div>
        </div>
    </div>
</template>

<script>

const API_PROXY = 'https://bird.ioliu.cn/v1/?url=' 
import { Toast } from 'mint-ui'

export default {
  data(){
            return {
                key: 'mOXWxbcX4KQryBFuIoLJ7GOzp0C2G4OZ',
                comment: []    //图文数据
            }
  },
  created() {
      this.getComments()
  },
  methods: {
      getComments(){
           let  _this = this
            _this.$axios.get(API_PROXY + 'http://api.tbk.dingdanxia.com/shop/getfeedback?apikey='
            + _this.key + '&id=539801480973')
                  .then(function (response) {
                         console.log(response.data.data)
                         _this.comment = response.data.data
                        
                         console.log(_this.comment)
                        })
                        .catch(function (err) {
                        Toast(err)
                        })
      },
      postComment(){

      }
  } 
}
</script>

<style lang="scss" scoped>
.cmt-container{
    h3{
        font-size: 18px;
    }
    textarea{
        font-size: 14px;
        height: 85px;
        margin: 0;
    }
    .cmt-list{
        margin: 5px 0;
        .cmt-item{
            font-size: 13px;
            .cmt-title{
              line-height: 30px;
              background-color: #ccc;   
            }
            .cmt-body{
               line-height: 37px;  
               text-indent: 2em;   
                }
        }
    }
}
</style>